//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package org.tuiofx.internal.test;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.input.DragEvent;
import javafx.scene.input.MouseDragEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Paint;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import org.tuiofx.Configuration;
import org.tuiofx.TuioFX;

public class DragExplore extends Application {
    LinkedHashMap queue = new LinkedHashMap<Integer, String>() {
        protected boolean removeEldestEntry(Map.Entry<Integer, String> eldest) {
            return this.size() > 10;
        }
    };
    Label console;

    public DragExplore() {
    }

    public void start(Stage primaryStage) throws Exception {
        Pane root = new Pane();
        final Scene scene = new Scene(root, 1920.0, 1080.0);
        this.console = new Label("Start…");
        this.console.setFont(new Font(8.0));
        Rectangle rect = new Rectangle(200.0, 200.0, Paint.valueOf("Red"));
        rect.setLayoutX(300.0);
        rect.setLayoutY(300.0);
        root.getChildren().addAll(new Node[]{this.console, rect});
        root.setOnDragDetected(new EventHandler<MouseEvent>() {
            public void handle(MouseEvent ev) {
                scene.startFullDrag();
                DragExplore.this.queue.put(System.currentTimeMillis(), ev.toString());
                DragExplore.this.fillLabel();
            }
        });
        root.setOnMouseDragged(new EventHandler<MouseEvent>() {
            public void handle(MouseEvent ev) {
                DragExplore.this.queue.put(System.currentTimeMillis(), ev.toString());
                DragExplore.this.fillLabel();
            }
        });
        rect.setOnMouseDragEntered(new EventHandler<MouseDragEvent>() {
            public void handle(MouseDragEvent ev) {
                DragExplore.this.queue.put(System.currentTimeMillis(), ev.toString());
                DragExplore.this.fillLabel();
            }
        });
        rect.setOnMouseDragExited(new EventHandler<MouseDragEvent>() {
            public void handle(MouseDragEvent ev) {
                DragExplore.this.queue.put(System.currentTimeMillis(), ev.toString());
                DragExplore.this.fillLabel();
            }
        });
        root.setOnDragDone(new EventHandler<DragEvent>() {
            public void handle(DragEvent ev) {
                DragExplore.this.queue.put(System.currentTimeMillis(), ev.toString());
                DragExplore.this.fillLabel();
            }
        });
        root.setOnDragOver(new EventHandler<DragEvent>() {
            public void handle(DragEvent ev) {
                DragExplore.this.queue.put(System.currentTimeMillis(), ev.toString());
                DragExplore.this.fillLabel();
            }
        });
        rect.setOnDragOver(new EventHandler<DragEvent>() {
            public void handle(DragEvent ev) {
                DragExplore.this.queue.put(System.currentTimeMillis(), ev.toString());
                DragExplore.this.fillLabel();
            }
        });
        TuioFX tuiofx = new TuioFX(primaryStage, Configuration.debug());
        tuiofx.start();
        primaryStage.setTitle("Hello Widgets");
        primaryStage.setScene(scene);
        primaryStage.setFullScreen(true);
        primaryStage.show();
    }

    private void fillLabel() {
        String text = "";

        for(Iterator iterator = this.queue.values().iterator(); iterator.hasNext(); text = text + (String)iterator.next() + "\n") {
        }

        this.console.setText(text);
    }

    public static void main(String[] args) {
        TuioFX.enableJavaFXTouchProperties();
        launch(args);
    }
}
